<?php
// +----------------------------------------------------------------------
// | najing [ 通用后台管理系统 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2020 http://www.najingquan.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: lin
// +----------------------------------------------------------------------

namespace app\admin\middleware;

use think\Db;
use think\facade\Request;

/**
 * 校检token
 */
class ValidateToken
{
    //需要校检的控制器和方法
    private function getConf()
    {
        //结构：控制器@方法名
        return [
            'user/editpoint.html',
        ];
    }

    public function handle($request, \Closure $next)
    {
        $validateToken = config('app.validate_token');
        if ($request->isPost() && $validateToken) {
            $validateMethod = $this->getConf();
            $pathinfo       = strtolower($request->pathinfo());
            if (in_array($pathinfo, $validateMethod)) {
                 validateShopToken();
            }
        }
        return $next($request);
    }

}